package com.azdebugit.clone.copy.cp.constructors;


public class DeepCar {
    DeepCar.Wheel wheel;
    String manufacturer;

    public DeepCar(DeepCar.Wheel wheel, String manufacturer) {
        this.wheel = wheel;
        this.manufacturer = manufacturer;
    }

    //深拷贝copy constructor
    public DeepCar(DeepCar car) {
        Wheel wheel = new Wheel();
        wheel.brand = car.wheel.brand;

        this.wheel = wheel;
        this.manufacturer = car.manufacturer;
    }

    public static class Wheel {
        String brand;
    }
    //深拷贝
    //使用Serializable实现深拷贝
    public static DeepCar newInstance(DeepCar car) {
        return new DeepCar(car);
    }
}
